package com.tlxch.controller.general;

import com.tlxch.pojo.SAttitudeWithBLOBs;
import com.tlxch.result.Result;
import com.tlxch.server.general.TattitudeService;
import com.tlxch.utils.TextSpecialWordChecker;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@Api(tags = "态度相关接口")
@Slf4j
@RestController
@RequestMapping("/attitude")
public class TAttitudeController {
    @Autowired
    TattitudeService tattitudeService;

    @PostMapping("/add")
    @ApiOperation("添加学习态度")
    public Result addAttitude(@RequestBody SAttitudeWithBLOBs sAttitude){
        int i = TextSpecialWordChecker.checkText(sAttitude.getSaAcontent());
        int i1 = TextSpecialWordChecker.checkText(sAttitude.getSaPlan());
        if (i == 0 || i1 == 0){
            return Result.error("文本内容中含有敏感词汇");
        }
        tattitudeService.addAttitude(sAttitude);
        return Result.success();
    }
}
